/*
 * Copyright (c) 2012 Jonathan Tyers
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.org.uplink.configproxy;

import java.lang.reflect.Method;

class Defaults {
	/**
	 * A default config proxy, the metadata of which is used for interfaces/methods
	 * that do not have @ConfigProxy or @ConfigValue annotations.
	 * 
	 * @author stevemash
	 */
	@ConfigProxy @SuppressWarnings("unused")
	private static class DefaultValuesClass {
		@ConfigValue(key = "")
		// NOTE do not rename this method without consulting #getConfigValueAnnotation()
		void defaultMethod() {
		}
	}

	public static ConfigValue getDefaultConfigValueAnnotation() {
		try {
			Method defaultMethod = DefaultValuesClass.class.getDeclaredMethod("defaultMethod");
			return defaultMethod.getAnnotation(ConfigValue.class);

		} catch (NoSuchMethodException e) {
			throw new RuntimeException(e); // cant happen
		}
	}

	public static ConfigProxy getDefaultConfigProxyAnnotation() {
		return DefaultValuesClass.class.getAnnotation(ConfigProxy.class);
	}
}
